package com.geezdata.cps.sdk3rd.jushita.enums;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.geezdata.cps.base.enums.BaseEnum;
import com.geezdata.cps.base.enums.ErrorCode;
import com.geezdata.cps.base.exceptions.MyException;

public enum RefundStatus implements BaseEnum {
	WAIT_SELLER_AGREE(1, "买家已经申请退款，等待卖家同意"),
	WAIT_BUYER_RETURN_GOODS(2, "卖家已经同意退款，等待买家退货"),
	WAIT_SELLER_CONFIRM_GOODS(3, "买家已经退货，等待卖家确认收货"),
	SELLER_REFUSE_BUYER(4, "卖家拒绝退款"),
	CLOSED(5, "退款关闭"),
	SUCCESS(11, "退款成功");

    private Integer code;
    private String desc;
    private static final Logger logger = LoggerFactory.getLogger(RefundStatus.class);


    RefundStatus(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    @Override
    public int getCode() {
        return this.code;
    }

    @Override
    public String getDesc() {
        return this.desc;
    }

    public static RefundStatus getByCode(Integer code) {
        for (RefundStatus orderStatusEnum : values()) {
            if (orderStatusEnum.getCode() == code.intValue()) {
                return orderStatusEnum;
            }
        }
        logger.error( "refund status not exists.Code is " + code);
        throw new MyException(ErrorCode.INTERNAL_SERVER_ERROR);
    }
}
